home *** CD-ROM | disk | FTP | other *** search
/ Programming a Multiplayer FPS in DirectX / Programming a Multiplayer FPS in DirectX (Companion CD).iso / DirectX / dxsdk_oct2004.exe / dxsdk.exe / Samples / Managed / Misc / DxDiagOutput / dxdiag.cs next >
Encoding:
Text File  |  2004-09-27  |  2.1 KB  |  71 lines

  1. //----------------------------------------------------------------------------
  2. // File: dxdiag.cs
  3. //
  4. // Desc: Sample app to read info from the DirectX Diagnostic Tool (DxDiag) by enumeration
  5. //
  6. // Copyright (c) Microsoft Corp. All rights reserved.
  7. //-----------------------------------------------------------------------------
  8. using System;
  9. using Microsoft.DirectX.Diagnostics;
  10.  
  11. namespace DxDiagOutput
  12. {
  13.     class DxDiagDisplay
  14.     {
  15.         static void Main(string[] args)
  16.         {
  17.             try
  18.             {
  19.                 // Just start our recursive loop with our root container.  Don't worry
  20.                 // about checking Whql
  21.                 OutputDiagData(null, new Container(false));
  22.             }
  23.             catch
  24.             {
  25.                 // Something bad happened
  26.             }
  27.         }
  28.  
  29.  
  30.  
  31.  
  32.         /// <summary>
  33.         /// Recursivly print the properties the root node and all its child to the console window
  34.         /// </summary>
  35.         /// <param name="parent">A string to display to show the root node of this data</param>
  36.         /// <param name="root">The actual container for this data.</param>
  37.         static void OutputDiagData(string parent, Container root)
  38.         {
  39.             try
  40.             {
  41.                 foreach (PropertyData pd in root.Properties)
  42.                 {
  43.                     // Just display the data
  44.                     Console.WriteLine("{0}.{1} = {2}", parent, pd.Name, pd.Data);
  45.                 }
  46.             }
  47.             catch
  48.             {
  49.             }
  50.  
  51.             try
  52.             {
  53.                 foreach (ContainerData cd in root.Containers)
  54.                 {
  55.                     // Recurse all the internal nodes
  56.                     if (parent == null)
  57.                         OutputDiagData(cd.Name, cd.Container);
  58.                     else
  59.                         OutputDiagData(parent + "." + cd.Name, cd.Container);
  60.                 }
  61.             }
  62.             catch 
  63.             {
  64.             }
  65.             
  66.             // We are done with this container, we can dispose it.
  67.             root.Dispose();
  68.         }
  69.     }
  70. }
  71.